package cn.cqs.redisitem.service;


import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

public class WindowsConditional implements Condition {


    @Override
    public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
       //获取bean工厂，通过配置列表
//        ConfigurableListableBeanFactory listableBeanFactory=conditionContext.getBeanFactory();
        //获取类加载器
//        ClassLoader cl = conditionContext.getClassLoader();
        //获取环境
        Environment env=conditionContext.getEnvironment();
        //获取bean注册 BeanDefinitionRegistry
//        BeanDefinitionRegistry registry= conditionContext.getRegistry();
        String property = env.getProperty("os.name");
        if(property.contains("Windows")){
            return true;
        }
        return false;
    }
}
